import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const store = new Vuex.Store({
	state: {
		userInfo: {},
		loginState: false
	},
	mutations: {
		login(state, provider) {
			state.loginState = true
			state.userInfo = provider
			uni.setStorageSync("userInfo",provider)
			// uni.setStorageSync({
			// 	key: 'userInfo',
			// 	data: provider
			// })
			console.log(provider)
			uni.setStorageSync("loginState",true)
		},
		logout(state) {
			state.loginState = false
			state.userInfo = {}
			uni.removeStorage({
				key: 'userInfo'
			});
			uni.setStorageSync("loginState",false)
		},
		setUserInfo(state, provider){
			state.userInfo.userInfo = provider
			uni.setStorageSync("userInfo",state.userInfo)
		},
		setLoginState(state, provider){
			state.loginState = true
		},
	}
})

export default store